package com.karolak.stock.oscilator;

import java.util.List;

import com.karolak.stock.data.DataManager;
import com.karolak.stock.indicator.Indicator;

public class CrossCounterOsc extends Indicator {

	/**
	 * @param dataManager
	 * @param period
	 * @param input
	 */
	public CrossCounterOsc(DataManager dataManager, int period, Indicator indicator) {
		super(dataManager, period, indicator);
	}

	public double execute(double x) {
		if (getPeriod() == 0) {
			return 0;
		}
		List<Double> values = getDataManager().getData(getInput().getName(), getPeriod());
		double sum = 0;
		for (double d : values) {
			if (d != 0) {
				sum = sum + 1;
			}
		}
		double v = sum;// / getPeriod();
		return v;
	}
}
